package com.icss.ah.fullGift.service;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.icss.ah.base.bean.EasyuiDataGridJson;

@Service
public class FullGiftStatisticsService {
	
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	private final Logger errlog = Logger.getLogger("E");
	private final Logger infolog = Logger.getLogger("I");
	private EasyuiDataGridJson dataGridJson = new EasyuiDataGridJson();
	
	/**
	 * 满赠活动查询
	 */
	public EasyuiDataGridJson queryGiftList(Map<String, String> map){
		try {
			List<Map<String, Object>> list = sqlSessionTemplate.selectList("FullGiftStatisticsBean.queryGiftList",map);
			Long total = sqlSessionTemplate.selectOne("FullGiftStatisticsBean.queryGiftListCount",map);
			dataGridJson.setRows(list);
			dataGridJson.setTotal(total);
			infolog.info("FullGiftStatisticsService|queryGiftList|para:"+map+"|list:"+list);
		} catch (Exception e) {
			errlog.error("FullGiftStatisticsService|queryGiftList",e);
		}
		return dataGridJson;
	}
	
	public EasyuiDataGridJson queryOrderList(Map<String, String> map){
		try {
			List<Map<String, Object>> list = sqlSessionTemplate.selectList("FullGiftStatisticsBean.queryOrderList",map);
			Long total = sqlSessionTemplate.selectOne("FullGiftStatisticsBean.queryOrderListCount",map);
			dataGridJson.setRows(list);
			dataGridJson.setTotal(total);
			infolog.info("FullGiftStatisticsService|queryOrderList|para:"+map+"|list:"+list);
		} catch (Exception e) {
			errlog.error("FullGiftStatisticsService|queryOrderList",e);
		}
		return dataGridJson;
	}

}
